﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<!-- saved from url=(0029)http://www.helpandmanual.com/ -->
<head><script type="text/javascript" src="helpman_topicinit.js"></script>
<!-- Redirect browser to frame page if page is not in the content frame. -->
<script type="text/javascript">
<!--
if(top.frames.length==0) { top.location.href="index.html?npc.htm"; }
else { parent.quicksync('a4.4'); }
//-->
</script>
<script type="text/javascript" src="highlight.js"></script>
   <title>Npc</title>
   <meta name="generator" content="Help &amp; Manual" />
   <meta name="keywords" content="" />
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <meta http-equiv="Content-Style-Type" content="text/css" />
   <link type="text/css" href="default.css" rel="stylesheet" />
</head>
<body style="margin: 0px 0px 0px 0px; background: #FFFFFF;" onload="highlight();">
<div id="hmpopupDiv" style="visibility:hidden; position:absolute; z-index:1000; "></div>


<table width="100%" border="0" cellspacing="0" cellpadding="5" bgcolor="#649CCC">
  <tr valign="middle">
    <td align="left">
      <p class="p_Heading1"><span class="f_Heading1">Npc</span></p>

    </td>
    <td align="right">
     <span style="font-size: 9pt">
     <a href="introduction.htm">Top</a>&nbsp;
     <a href="mailbox.htm">Previous</a>&nbsp;
     <a href="ship.htm">Next</a>
     </span>
    </td>
  </tr>
</table>


<!-- Placeholder for topic body. -->
<table width="100%" border="0" cellspacing="0" cellpadding="5"><tr valign="top"><td align="left">
<p>Npc class provides all needed methods for npcs.</p>
<p>&nbsp;</p>
<p>Example code:</p>
<p>&nbsp;</p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">using</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> System;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">using</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> System.Collections.Generic;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">using</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> SagaMap;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">using</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> SagaDB.Actors;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">using</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> SagaDB.Items;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">public</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">class</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">Waynedi</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> : </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">Npc</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">{</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">public</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">override</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">void</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> OnInit()</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; {</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MapName = </span><span style="font-size: 9pt; font-family: '新宋体'; color: #800000;">&quot;Hod_f00&quot;</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Type = 1140;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name = </span><span style="font-size: 9pt; font-family: '新宋体'; color: #800000;">&quot;Waynedi Arga&quot;</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StartX = 8922F;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StartY = -11445F;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; StartZ = 697F;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Startyaw = 42000;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetScript(3);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddQuestStep(401, 40103, </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">StepStatus</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">.Active);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddButton(</span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">Functions</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">.EverydayConversation, </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">new</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">func</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">(OnButton));</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddButton(</span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">Functions</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">.Smith);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AddButton(</span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">Functions</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">.OfficialQuest, </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">new</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">func</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">(OnQuest), </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">true</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; }</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">public</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">void</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> OnButton(</span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">ActorPC</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> pc)</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; {</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NPCChat(pc, 823);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; }</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">public</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">void</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> OnQuest(</span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">ActorPC</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> pc)</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; {</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">if</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> (GetQuestStepStatus(pc, 401, 40103) == </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">StepStatus</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">.Active)</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UpdateQuest(pc, 401, 40103, </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">StepStatus</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">.Completed);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QuestCompleted(pc, 401);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; UpdateIcon(pc, </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">IconType</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">.None);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NPCChat(pc, 0);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SetReward(pc, </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">new</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">rewardfunc</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">(OnReward));</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; }</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">public</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">void</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> OnReward(</span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">ActorPC</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> pc, </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">uint</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> QID)</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; {</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">if</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> (QID == 401)</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GiveExp(pc, 140, 50);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; GiveZeny(pc, 5);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RemoveNavPoint(pc, 401);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RemoveQuest(pc, 401);</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> &nbsp;&nbsp; }</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">}</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; color: #000000;">All classes for NPC should be inherited from Npc class or class that is child of Npc class.</span></p>
<p><span style="font-size: 9pt; color: #000000;">Initialiation is done in OnInit method, never write a constructor!</span></p>
<p><span style="font-size: 9pt; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; color: #000000;">The following field should be set in OnInit method:</span></p>
<p><span style="font-size: 9pt; color: #000000;">MapName //Name of the map</span></p>
<p><span style="font-size: 9pt; color: #000000;">Type // Type of a npc</span></p>
<p><span style="font-size: 9pt; color: #000000;">Name // Name of a npc</span></p>
<p><span style="font-size: 9pt; color: #000000;">StartX // starting position</span></p>
<p><span style="font-size: 9pt; color: #000000;">StartY</span></p>
<p><span style="font-size: 9pt; color: #000000;">StartZ</span></p>
<p><span style="font-size: 9pt; color: #000000;">Startyaw //starting heading direction</span></p>
<p><span style="font-size: 9pt; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; color: #000000;">the following methods can only or should be used in OnInit method:</span></p>
<p><span style="font-size: 9pt; color: #000000;">SetScript,AddQuestStep,AddButton,AddGoods,AddMobLoot,AddQuestItem</span></p>
<p><span style="font-size: 9pt; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; color: #000000;">Methods, that could be overridden, besides OnInit:</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">void</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> OnActorAppears(</span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">Actor</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> dActor)//this function is called when a Actor is getting into current Npc's sight range</span></p>
<p><span style="font-size: 9pt; font-family: '新宋体'; color: #0000ff;">void</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> OnActorDisappears(</span><span style="font-size: 9pt; font-family: '新宋体'; color: #008080;">Actor</span><span style="font-size: 9pt; font-family: '新宋体'; color: #000000;"> dActor)//this function is called when a Actor is going out of current Npc's sight range</span></p>
<p><span style="font-size: 9pt; color: #000000;">&nbsp;</span></p>
<p><span style="font-size: 9pt; color: #000000;">&nbsp;</span></p>

</td></tr></table>

</body>
</html>
